<template>
    <view class="body">
        <view class="search-box search">
            <view class="search-icon" @click="search">
                <u-icon name="search" class="pms-icon search-icon-son"></u-icon>
            </view>
            <view class="input-box search-input">
                <input
                  class="input-query"
                  v-model="labelId"
                  focus
                  placeholder="请输入原标签ID或扫描原标签"
                  @confirm="search"
                />
                <image @click="scan" class="query-icon pms-icon"
                       src="../../static/imges/saomiaohui.png" mode=""></image>
            </view>
        </view>

    </view>
</template>

<script>

export default {
    data() {
        return {
            labelId:''
        }
    },
    onLoad(option) {
      uni.setStorageSync("sysToken", option.sysToken)
    },
    methods:{
        search() {
          //需要知道属于主材3、服务1、辅材2、非外市电力电缆4
          this.$axios.get('/material/api/app/pubSwapLabel/querySwapLabelInfo',{labelId:this.labelId}).then((res)=>{
            let { data } = res
            uni.showModal({
              confirmColor: '#eb4b4b',
              title: "温馨提示",
              content: "除标签丢失、无法扫码识别、标签类型错误、质保期内更换实物外，厂家源头贴码物资禁止随意更换标签，铁塔公司将对不按规定换签的施工单位通报考核。请再次核实本次换签是否合规。",
              success:(result)=>{
                if(result.confirm){
                  uni.navigateTo({
                    url:
                        "/inspur/changeLabel/changeLabelCheck?item=" + encodeURIComponent(JSON.stringify(data)) + "&item1=" + encodeURIComponent(JSON.stringify(data)) + "&item2=" + encodeURIComponent(JSON.stringify(data))+
                        "&index="+data.viewType+"&prjId=" + data.prjId,
                  });
                  console.log("换签按钮")
                }else{
                  console.log('取消操作')
                }
              }
            });
          })
        },
        scan() {
            let that = this
            imp.iBarCode.scan(function (result) {
                console.log('扫描结果',result)
                that.labelId = result;
                that.search();
            });
        }
    }
}
</script>
<style>
@import "@/common/common-ui.css";
</style>
<style scoped lang="scss">
.body {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: #f7f8fa;
    padding-top: 10rpx;
}
.search {
    font-size: 24rpx;
    padding: 16rpx;
}
.search-box {
    position: relative;
}
.input-query {
    width: 100%;
    height: 90rpx;
    padding-left: 72rpx;
    box-sizing: border-box;
    border-radius: 80rpx;
    background: #fff;
    font-size: 24rpx;
}
.search-input {
    position: relative;
    display: flex;
}
.search-icon {
    z-index: 9;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: calc(50% - 24rpx);
    left: calc(30rpx);
    width: 48rpx;
    height: 48rpx;
}
.search-icon-son {
    font-size: 40rpx;
}
.query-icon {
    width: 50rpx;
    height: 50rpx;
    margin-left: 20rpx;
    margin-top: 20rpx;
}

</style>
